package com.tianyin.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.tianyin.entity.User;
import com.tianyin.service.UserService;




/**
 * 用户登录Controller
 * @author Airean
 * @date 2015年12月18日
 *
 */
@Controller
@RequestMapping("/user")
public class UserLoginController {
	
	private static Logger log = Logger.getLogger(UserLoginController.class);
	
	@Autowired
	private UserService userService;
	
	@RequestMapping(value = "/logon", method = RequestMethod.POST)
	public String saveLogin( String account, String password,ModelMap modelMap){
		try {
			log.info("dsfsfsffffffff");
			User user = userService.findUser(account, password);
			userService.saveUser();
		} catch (Exception e) {
			log.error("登陆失败: "+e.getMessage(), e.fillInStackTrace());
			e.printStackTrace();
			return "account_list";
		}
		modelMap.addAttribute("test", "你好");
		return "account_list";
	}
	
	
}
